home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 3 / ct-rom iiib.zip / ct-rom iiib / WINDOWS / DIVERSEN / WINE02BX / EMACS.4 < prev    next >
Text File  |  1993-03-28  |  45KB  |  1,070 lines

  1. Info file ../info/emacs, produced by Makeinfo, -*- Text -*- from input
  2. file lemacs.tex.
  3.  
  4.    This file documents the GNU Emacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  7. 1991, 1992 Lucid, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of
  10. this manual provided the copyright notice and this permission notice
  11. are preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  16. General Public License" are included exactly as in the original, and
  17. provided that the entire resulting derived work is distributed under
  18. the terms of a permission notice identical to this one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "The GNU Manifesto",
  23. "Distribution" and "GNU General Public License" may be included in a
  24. translation approved by the author instead of in the original English.
  25.  
  26. 
  27. File: emacs,  Node: Killing,  Next: Yanking,  Prev: Mark,  Up: Top
  28.  
  29. Deletion and Killing
  30. ====================
  31.  
  32.    Most commands which erase text from the buffer save it. You can get
  33. the text back if you change your mind, or you can move or copy it to
  34. other parts of the buffer.  Commands which erase text and save it in
  35. the kill ring are known as "kill" commands.  Some other commands erase
  36. text but do not save it; they are known as "delete" commands.  (This
  37. distinction is made only for erasing text in the buffer.)
  38.  
  39.    The commands' names and individual descriptions use the words
  40. `kill' and `delete' to indicate what they do.  If you perform a kill
  41. or delete command by mistake, use the `C-x u' (`undo') command to undo
  42. it (*note Undo::.). The delete commands include `C-d' (`delete-char')
  43. and DEL (`delete-backward-char'), which delete only one character at a
  44. time, and those commands that delete only spaces or newlines. 
  45. Commands that can destroy significant amounts of nontrivial data
  46. usually kill.
  47.  
  48. Deletion
  49. --------
  50.  
  51. `C-d'
  52.      Delete next character (`delete-char').
  53.  
  54. `DEL'
  55.      Delete previous character (`delete-backward-char').
  56.  
  57. `M-\'
  58.      Delete spaces and tabs around point (`delete-horizontal-space').
  59.  
  60. `M-SPC'
  61.      Delete spaces and tabs around point, leaving one space
  62.      (`just-one-space').
  63.  
  64. `C-x C-o'
  65.      Delete blank lines around the current line (`delete-blank-lines').
  66.  
  67. `M-^'
  68.      Join two lines by deleting the intervening newline, and any
  69.      indentation following it (`delete-indentation').
  70.  
  71.    The most basic delete commands are `C-d' (`delete-char') and DEL
  72. (`delete-backward-char').  `C-d' deletes the character after point,
  73. the one the cursor is "on top of".  Point doesn't move.  DEL deletes
  74. the character before the cursor, and moves point back.  You can delete
  75. newlines like any other characters in the buffer; deleting a newline
  76. joins two lines.  Actually, `C-d' and DEL aren't always delete
  77. commands; if you give them an argument, they kill instead, since they
  78. can erase more than one character this way.
  79.  
  80.    The other delete commands delete only formatting characters: spaces,
  81. tabs and newlines.  `M-\' (`delete-horizontal-space') deletes all
  82. spaces and tab characters before and after point.  `M-SPC'
  83. (`just-one-space') does the same but leaves a single space after
  84. point, regardless of the number of spaces that existed previously
  85. (even zero).
  86.  
  87.    `C-x C-o' (`delete-blank-lines') deletes all blank lines after the
  88. current line. If the current line is blank, it deletes all blank lines
  89. preceding the current line as well as leaving one blank line, the
  90. current line.  `M-^' (`delete-indentation') joins the current line and
  91. the previous line, or the current line and the next line if given an
  92. argument, by deleting a newline and all surrounding spaces, possibly
  93. leaving a single space.  *Note M-^: Indentation.
  94.  
  95. Killing by Lines
  96. ----------------
  97.  
  98. `C-k'
  99.      Kill rest of line or one or more lines (`kill-line').
  100.  
  101.    The simplest kill command is `C-k'.  If given at the beginning of a
  102. line, it kills all the text on the line, leaving the line blank.  If
  103. given on a blank line, the blank line disappears.  As a consequence, a
  104. line disappears completely if you go to the front of a non-blank line
  105. and type `C-k' twice.
  106.  
  107.    More generally, `C-k' kills from point up to the end of the line,
  108. unless it is at the end of a line.  In that case, it kills the newline
  109. following the line, thus merging the next line into the current one. 
  110. Emacs ignores invisible spaces and tabs at the end of the line when
  111. deciding which case applies: if point appears to be at the end of the
  112. line, you can be sure the newline will be killed.
  113.  
  114.    If you give `C-k' a positive argument, it kills that many lines and
  115. the newlines that follow them (however, text on the current line
  116. before point is not killed).  With a negative argument, `C-k' kills
  117. back to a number of line beginnings.  An argument of -2 means kill
  118. back to the second line beginning.  If point is at the beginning of a
  119. line, that line beginning doesn't count, so `C-u - 2 C-k' with point
  120. at the front of a line kills the two previous lines.
  121.  
  122.    `C-k' with an argument of zero kills all the text before point on
  123. the current line.
  124.  
  125. Other Kill Commands
  126. -------------------
  127.  
  128. `C-w'
  129.      Kill region (from point to the mark) (`kill-region').  *Note
  130.      Words::.
  131.  
  132. `M-d'
  133.      Kill word (`kill-word').
  134.  
  135. `M-DEL'
  136.      Kill word backwards (`backward-kill-word').
  137.  
  138. `C-x DEL'
  139.      Kill back to beginning of sentence (`backward-kill-sentence'). 
  140.      *Note Sentences::.
  141.  
  142. `M-k'
  143.      Kill to end of sentence (`kill-sentence').
  144.  
  145. `C-M-k'
  146.      Kill sexp (`kill-sexp').  *Note Lists::.
  147.  
  148. `M-z CHAR'
  149.      Kill up to next occurrence of CHAR (`zap-to-char').
  150.  
  151.    `C-w' (`kill-region') is a very general kill command; it kills
  152. everything between point and the mark. You can use this command to
  153. kill any contiguous sequence of characters by first setting the mark at
  154. one end of a sequence of characters, then going to the other end and
  155. typing `C-w'.
  156.  
  157.    A convenient way of killing is combined with searching: `M-z'
  158. (`zap-to-char') reads a character and kills from point up to (but not
  159. including) the next occurrence of that character in the buffer.  If
  160. there is no next occurrence, killing goes to the end of the buffer.  A
  161. numeric argument acts as a repeat count.  A negative argument means to
  162. search backward and kill text before point.
  163.  
  164.    Other syntactic units can be killed: words, with `M-DEL' and `M-d'
  165. (*note Words::.); sexps, with `C-M-k' (*note Lists::.); and sentences,
  166. with `C-x DEL' and `M-k' (*note Sentences::.).
  167.  
  168. 
  169. File: emacs,  Node: Yanking,  Next: Using X Selections,  Prev: Killing,  Up: Top
  170.  
  171. Yanking
  172. =======
  173.  
  174.    "Yanking" means getting back text which was killed. Some systems
  175. call this "pasting".  The usual way to move or copy text is to kill it
  176. and then yank it one or more times.
  177.  
  178. `C-y'
  179.      Yank last killed text (`yank').
  180.  
  181. `M-y'
  182.      Replace re-inserted killed text with the previously killed text
  183.      (`yank-pop').
  184.  
  185. `M-w'
  186.      Save region as last killed text without actually killing it
  187.      (`copy-region-as-kill').
  188.  
  189. `C-M-w'
  190.      Append next kill to last batch of killed text
  191.      (`append-next-kill').
  192.  
  193. * Menu:
  194.  
  195. * Kill Ring::       Where killed text is stored.  Basic yanking.
  196. * Appending Kills:: Several kills in a row all yank together.
  197. * Earlier Kills::   Yanking something killed some time ago.
  198.  
  199. 
  200. File: emacs,  Node: Kill Ring,  Next: Appending Kills,  Prev: Yanking,  Up: Yanking
  201.  
  202. The Kill Ring
  203. -------------
  204.  
  205.    All killed text is recorded in the "kill ring", a list of blocks of
  206. text that have been killed.  There is only one kill ring, used in all
  207. buffers, so you can kill text in one buffer and yank it in another
  208. buffer.  This is the usual way to move text from one file to another. 
  209. (*Note Accumulating Text::, for some other ways.)
  210.  
  211.    If you have two separate Emacs processes, you cannot use the kill
  212. ring to move text. If you are using Lucid GNU Emacs under X, you can,
  213. however, use the X selection mechanism to move text from one to
  214. another.
  215.  
  216.    If you are using Lucid GNU Emacs under X and have one Emacs process
  217. with multiple screens, they do share the same kill ring.  You can kill
  218. or copy text in one Emacs screen, then yank it in the other screen
  219. belonging to the same process.
  220.  
  221.    The command `C-y' (`yank') reinserts the text of the most recent
  222. kill.  It leaves the cursor at the end of the text and sets the mark at
  223. the beginning of the text.  *Note Mark::.
  224.  
  225.    `C-u C-y' yanks the text, leaves the cursor in front of the text,
  226. and sets the mark after it, if the argument is with just a `C-u'.  Any
  227. other argument, including `C-u' and digits, has different results,
  228. described below, under "Yanking Earlier Kills".
  229.  
  230.    To copy a block of text, you can also use `M-w'
  231. (`copy-region-as-kill'), which copies the region into the kill ring
  232. without removing it from the buffer. `M-w' is similar to `C-w'
  233. followed by `C-y' but does not mark the buffer as "modified" and does
  234. not actually cut anything.
  235.  
  236. 
  237. File: emacs,  Node: Appending Kills,  Next: Earlier Kills,  Prev: Kill Ring,  Up: Yanking
  238.  
  239. Appending Kills
  240. ---------------
  241.  
  242.    Normally, each kill command pushes a new block onto the kill ring. 
  243. However, two or more kill commands in a row combine their text into a
  244. single entry, so that a single `C-y' yanks it all back. This means you
  245. don't have to kill all the text you want to yank in one command; you
  246. can kill line after line, or word after word, until you have killed
  247. what you want, then get it all back at once using `C-y'. (Thus we join
  248. television in leading people to kill thoughtlessly.)
  249.  
  250.    Commands that kill forward from point add onto the end of the
  251. previous killed text.  Commands that kill backward from point add onto
  252. the beginning.  This way, any sequence of mixed forward and backward
  253. kill commands puts all the killed text into one entry without
  254. rearrangement.  Numeric arguments do not break the sequence of
  255. appending kills.  For example, suppose the buffer contains
  256.  
  257.      This is the first
  258.      line of sample text
  259.      and here is the third.
  260.  
  261. with point at the beginning of the second line.  If you type `C-k C-u 2
  262. M-DEL C-k', the first `C-k' kills the text `line of sample text', `C-u
  263. 2 M-DEL' kills `the first' with the newline that followed it, and the
  264. second `C-k' kills the newline after the second line.  The result is
  265. that the buffer contains `This is and here is the third.' and a single
  266. kill entry contains `the firstRETline of sample textRET'--all the
  267. killed text, in its original order.
  268.  
  269.    If a kill command is separated from the last kill command by other
  270. commands (not just numeric arguments), it starts a new entry on the
  271. kill ring.  To force a kill command to append, first type the command
  272. `C-M-w' (`append-next-kill'). `C-M-w' tells the following command, if
  273. it is a kill command, to append the text it kills to the last killed
  274. text, instead of starting a new entry.  With `C-M-w', you can kill
  275. several separated pieces of text and accumulate them to be yanked back
  276. in one place.
  277.  
  278. 
  279. File: emacs,  Node: Earlier Kills,  Prev: Appending Kills,  Up: Yanking
  280.  
  281. Yanking Earlier Kills
  282. ---------------------
  283.  
  284.    To recover killed text that is no longer the most recent kill, you
  285. need the `Meta-y' (`yank-pop') command.  You can use `M-y' only after
  286. a `C-y' or another `M-y'.  It takes the text previously yanked and
  287. replaces it with the text from an earlier kill.  To recover the text
  288. of the next-to-the-last kill, first use `C-y' to recover the last
  289. kill, then `M-y' to replace it with the previous kill.
  290.  
  291.    You can think in terms of a "last yank" pointer which points at an
  292. item in the kill ring.  Each time you kill, the "last yank" pointer
  293. moves to the new item at the front of the ring.  `C-y' yanks the item
  294. which the "last yank" pointer points to.  `M-y' moves the "last yank"
  295. pointer to a different item, and the text in the buffer changes to
  296. match.  Enough `M-y' commands can move the pointer to any item in the
  297. ring, so you can get any item into the buffer.  Eventually the pointer
  298. reaches the end of the ring; the next `M-y' moves it to the first item
  299. again.
  300.  
  301.    Yanking moves the "last yank" pointer around the ring, but does not
  302. change the order of the entries in the ring, which always runs from the
  303. most recent kill at the front to the oldest one still remembered.
  304.  
  305.    Use `M-y' with a numeric argument, to tell to advance the "last
  306. yank" pointer by the specified number of items.  A negative argument
  307. moves the pointer toward the front of the ring; from the front of the
  308. ring, it moves to the last entry and starts moving forward from there.
  309.  
  310.    Once the text you are looking for is brought into the buffer, you
  311. can stop doing `M-y' commands and the text will stay there. Since the
  312. text is just a copy of the kill ring item, editing it in the buffer
  313. does not change what's in the ring.  As long you don`t kill additional
  314. text, the "last yank" pointer remains at the same place in the kill
  315. ring: repeating `C-y' will yank another copy of the same old kill.
  316.  
  317.    If you know how many `M-y' commands it would take to find the text
  318. you want, you can yank that text in one step using `C-y' with a
  319. numeric argument.  `C-y' with an argument greater than one restores
  320. the text the specified number of entries back in the kill ring.  Thus,
  321. `C-u 2 C-y' gets the next to the last block of killed text.  It is
  322. equivalent to `C-y M-y'.  `C-y' with a numeric argument starts
  323. counting from the "last yank" pointer, and sets the "last yank"
  324. pointer to the entry that it yanks.
  325.  
  326.    The variable `kill-ring-max' controls the length of the kill ring;
  327. no more than that many blocks of killed text are saved.
  328.  
  329. 
  330. File: emacs,  Node: Using X Selections,  Next: Accumulating Text,  Prev: Yanking,  Up: Top
  331.  
  332. Using X Selections
  333. ==================
  334.  
  335.    In the X window system, mouse selections provide a simple mechanism
  336. for text transfer between different applications.  In a typical X
  337. application, you can select text by pressing the left mouse button and
  338. dragging the cursor over the text you want to copy. The text becomes
  339. the primary X selection and is highlighted. The highlighted region is
  340. also the Emacs selected region.
  341.  
  342.    * Since the region is the primary X selection, you can go to a
  343.      different X application and click the middle mouse button: the
  344.      text that you selected in the previous application is pasted into
  345.      the current application.
  346.  
  347.    * Since the region is the Emacs selected region, you can use all
  348.      region commands (`C-w, M-w' etc.) as well as the options of the
  349.      Edit menu to manipulate the selected text.
  350.  
  351. * Menu:
  352.  
  353. * X Clipboard Selection::         Storing the primary selection.
  354. * X Selection Commands::    Other operations on the selection.
  355. * X Cut Buffers::           X cut buffers are available for compatibility.
  356. * Active Regions::          Using zmacs-style highlighting of the
  357.                              selected region.
  358.  
  359. 
  360. File: emacs,  Node: X Clipboard Selection,  Next: X Selection Commands,  Prev: Using X Selections,  Up: Using X Selections
  361.  
  362. The Clipboard Selection
  363. -----------------------
  364.  
  365.    There are other kinds of X selection besides the primary selection.
  366.  Each time a region of text is added to the kill ring (for example,
  367. with C-k, C-w, or M-w or with a Cut or Copy menu item), that text
  368. becomes the clipboard selection.
  369.  
  370.    Usually, the clipboard selection is not visible. However, if you run
  371. the `xclipboard' application, the most recently killed text--the value
  372. of the clipboard selection--is displayed in a window.  Any time Emacs
  373. adds text to the kill ring, the `xclipboard' application makes a copy
  374. of it and displays it in its window. The value of the clipboard can
  375. survive the lifetime of the running Emacs process. The `xclipboard'
  376. man page provides more details.
  377.  
  378.    Warning: If you use the `xclipboard' application, remember that it
  379. maintains a list of all things that have been pasted to the clipboard
  380. (that is, killed in Emacs).  If you don't manually delete elements from
  381. this list by clicking on the Delete button in the `xclipboard' window,
  382. the clipboard will eventually consume a lot of memory.
  383.  
  384. 
  385. File: emacs,  Node: X Selection Commands,  Next: X Cut Buffers,  Prev: X Clipboard Selection,  Up: Using X Selections
  386.  
  387. Miscellaneous X Selection Commands
  388. ----------------------------------
  389.  
  390. `M-x x-copy-primary-selection'
  391.      Copy the primary selection to both the kill ring and the
  392.      Clipboard.
  393.  
  394. `M-x x-insert-selection'
  395.      Insert the current selection into the buffer at point.
  396.  
  397. `M-x x-delete-primary-selection'
  398.      Deletes the text in the primary selection without copying it to
  399.      the kill ring or the Clipboard.
  400.  
  401. `M-x x-kill-primary-selection'
  402.      Deletes the text in the primary selection and copies it to both
  403.      the kill ring and the Clipboard.
  404.  
  405. `M-x x-mouse-kill'
  406.      Kill the text between point and the mouse and copy it to the
  407.      clipboard and to the cut buffer.
  408.  
  409. `M-x x-new-screen'
  410.      Create a new Emacs screen (that is, a new X window).
  411.  
  412. `M-x x-own-secondary-selection'
  413.      Make a secondary X selection of the given argument.
  414.  
  415. `M-x x-own-selection'
  416.      Make a primary X selection of the given argument.
  417.  
  418. `M-x x-set-point-and-insert-selection'
  419.      Set point where clicked and insert the primary selection or the
  420.      cut buffer.
  421.  
  422. 
  423. File: emacs,  Node: X Cut Buffers,  Next: Active Regions,  Prev: X Selection Commands,  Up: Using X Selections
  424.  
  425. X Cut Buffers
  426. -------------
  427.  
  428.    X cut buffers are a different, older way of transferring text
  429. between applications.  Lucid GNU Emacs supports cut buffers for
  430. compatibility with older programs, even though selections are now the
  431. preferred way of transferring text.
  432.  
  433.    X has a concept of applications "owning" selections.  When you
  434. select text by clicking and dragging inside an application, the
  435. application tells the X server that it owns the selection.  When
  436. another application asks the X server for the value of the selection,
  437. the X server requests the information from the owner. When you use
  438. selections, the selection data is not actually transferred unless
  439. someone wants it; the act of making a selection doesn't transfer data. 
  440. Cut buffers are different: when you "own" a cut buffer, the data is
  441. actually transferred to the X server immediately, and survives the
  442. lifetime of the application.
  443.  
  444.    Any time a region of text becomes the primary selection in Emacs,
  445. Emacs also copies that text to the cut buffer.  This makes it possible
  446. to copy text from a Lucid GNU Emacs buffer and paste it into an older,
  447. non-selection-based application (such as Emacs 18.)
  448.  
  449.    Note: Older versions of Emacs could not access the X selections,
  450. only the X cut buffers.
  451.  
  452. 
  453. File: emacs,  Node: Active Regions,  Prev: X Cut Buffers,  Up: Using X Selections
  454.  
  455. Active Regions
  456. --------------
  457.  
  458.    By default, both the text you select in an Emacs buffer using the
  459. click-and-drag mechanism and text you select by setting point and the
  460. mark is highlighted. You can use Emacs region commands as well as the
  461. Cut and Copy commands on the highlighted region you selected with the
  462. mouse.
  463.  
  464.    If you prefer, you can make a distinction between text selected
  465. with the mouse and text selected with point and the mark by setting
  466. the variable `zmacs-regions' to `nil'.  In that case:
  467.  
  468.    * The text selected with the mouse becomes both the X selection and
  469.      the Emacs selected region. You can use menubar commands as well
  470.      as Emacs region commands on it.
  471.  
  472.    * The text selected with point and the mark does not highlight. You
  473.      can only use Emacs region commands but not the menu bar items on
  474.      it.
  475.  
  476.    Active regions originally come from Zmacs, the Lisp Machine editor. 
  477. The idea behind them is that commands can only operate on a region when
  478. the region is in an "active" state.  Put simply, you can only operate
  479. on a region that is highlighted.
  480.  
  481.    The variable `zmacs-regions' checks whether LISPM-style active
  482. regions should be used.  This means that commands that operate on the
  483. region (the area between point and the mark) only work while the
  484. region is in the active state, which is indicated by highlighting. 
  485. Most commands causes the region to not be in the active state; for
  486. example, `C-w' only works immediately after activating the region.
  487.  
  488.    More specifically:
  489.  
  490.    * Commands that operate on the region only work if the region is
  491.      active.
  492.  
  493.    * Only a very small set of commands causes the region to become
  494.      active-- those commands whose semantics are to mark an area, such
  495.      as `mark-defun'.
  496.  
  497.    * The region is deactivated after each command that is executed,
  498.      except that motion commands do not change whether the region is
  499.      active or not.
  500.  
  501.    `set-mark-command' (`C-SPC') pushes a mark and activates the
  502. region.  Moving the cursor with normal motion commands (`C-n', `C-p',
  503. etc) will cause the region between point and the recently-pushed mark
  504. to be highlighted.  It will remain highlighted until some non-motion
  505. comand is executed.
  506.  
  507.    `exchange-point-and-mark' (`C-x C-x') activates the region.  So if
  508. you mark a region and execute a command that operates on it, you can
  509. reactivate the same region with `C-x C-x' (or perhaps `C-x C-x C-x
  510. C-x') to operate on it again.
  511.  
  512.    Generally, commands that push marks as a means of navigation, such
  513. as `beginning-of-buffer' (`M-<') and `end-of-buffer' (`M->'), do not
  514. activate the region.  However, commands that push marks as a means of
  515. marking an area of text, such as `mark-defun' (`M-C-h'), `mark-word'
  516. (`M-@'), and `mark-whole-buffer' (`C-x h'), do activate the region.
  517.  
  518.    When `zmacs-regions' is `t', there is no distinction between the
  519. primary X selection and the active region selected by point and the
  520. mark.  To see this, set the mark (C-SPC) and move the cursor with any
  521. cursor-motion command: the region between point and mark is
  522. highlighted, and you can watch it grow and shrink as you move the
  523. cursor.
  524.  
  525.    Any other commands besides cursor-motion commands (such as
  526. inserting or deleting text) will cause the region to no longer be
  527. active; it will no longer be highlighted, and will no longer be the
  528. primary selection.  Errors also remove highlighting from a region.
  529.  
  530.    Commands which require a region (such as `C-w') signal an error if
  531. the region is not active.  Certain commands cause the region to be in
  532. its active state.  The most common ones are `push-mark' (C-SPC) and
  533. `exchange-point-and-mark' (`C-x C-x').
  534.  
  535.    When `zmacs-regions' is `t', programs can be non-intrusive on the
  536. state of the region by setting the variable `zmacs-region-stays' to a
  537. non-`nil' value.  If you are writing a new emacs command that is
  538. conceptually a "motion" command, and should not interfere with the
  539. current highlightedness of the region, then you may set this variable. 
  540. It is reset to `nil' after each user command is executed.
  541.  
  542.    When `zmacs-regions' is `t', programs can make the region between
  543. point and mark go into the active (highlighted) state by using the
  544. function `zmacs-activate-region'. Only a small number of commands
  545. should ever do this.
  546.  
  547.    When `zmacs-regions' is `t', programs can deactivate the region
  548. between point and the mark by using `zmacs-deactivate-region'.  Note:
  549. you should not have to call this function; the command loop calls it
  550. when appropriate.
  551.  
  552. 
  553. File: emacs,  Node: Accumulating Text,  Next: Rectangles,  Prev: Using X Selections,  Up: Top
  554.  
  555. Accumulating Text
  556. =================
  557.  
  558.    Usually you copy or move text by killing it and yanking it, but
  559. there are other ways that are useful for copying one block of text in
  560. many places, or for copying many scattered blocks of text into one
  561. place.
  562.  
  563.    If you like, you can accumulate blocks of text from scattered
  564. locations either into a buffer or into a file.  The relevant commands
  565. are described here.  You can also use Emacs registers for storing and
  566. accumulating text.  *Note Registers::.
  567.  
  568. `C-x a'
  569.      Append region to contents of specified buffer
  570.      (`append-to-buffer').
  571.  
  572. `M-x prepend-to-buffer'
  573.      Prepend region to contents of specified buffer.
  574.  
  575. `M-x copy-to-buffer'
  576.      Copy region into specified buffer, deleting that buffer's old
  577.      contents.
  578.  
  579. `M-x insert-buffer'
  580.      Insert contents of specified buffer into current buffer at point.
  581.  
  582. `M-x append-to-file'
  583.      Append region to contents of specified file, at the end.
  584.  
  585.    To accumulate text into a buffer, use the command `C-x a
  586. BUFFERNAME' (`append-to-buffer'), which inserts a copy of the region
  587. into the buffer BUFFERNAME, at the location of point in that buffer. 
  588. If there is no buffer with the given name, one is created.
  589.  
  590.    If you append text to a buffer that has been used for editing, the
  591. copied text goes to the place where point is.  Point in that buffer is
  592. left at the end of the copied text, so successive uses of `C-x a'
  593. accumulate the text in the specified buffer in the same order as they
  594. were copied.  Strictly speaking, `C-x a' does not always append to the
  595. text already in the buffer; but if `C-x a' is the only command used to
  596. alter a buffer, it does always append to the existing text because
  597. point is always at the end.
  598.  
  599.    `M-x prepend-to-buffer' is similar to `C-x a' but point in the
  600. other buffer is left before the copied text, so successive prependings
  601. add text in reverse order.  `M-x copy-to-buffer' is similar except that
  602. any existing text in the other buffer is deleted, so the buffer is left
  603. containing just the text newly copied into it.
  604.  
  605.    You can retrieve the accumulated text from that buffer with `M-x
  606. insert-buffer', which takes BUFFERNAME as an argument.  It inserts a
  607. copy of the text in buffer BUFFERNAME into the selected buffer.  You
  608. could alternatively select the other buffer for editing, perhaps moving
  609. text from it by killing or with `C-x a'.  *Note Buffers::, for
  610. background information on buffers.
  611.  
  612.    Instead of accumulating text within Emacs, in a buffer, you can
  613. append text directly into a file with `M-x append-to-file', which takes
  614. FILE-NAME as an argument.  It adds the text of the region to the end
  615. of the specified file.  The file is changed immediately on disk.  This
  616. command is normally used with files that are not being visited in
  617. Emacs.  Using it on a file that Emacs is visiting can produce
  618. confusing results, because the file's text inside Emacs does not change
  619. while the file itself changes.
  620.  
  621. 
  622. File: emacs,  Node: Rectangles,  Next: Registers,  Prev: Accumulating Text,  Up: Top
  623.  
  624. Rectangles
  625. ==========
  626.  
  627.    The rectangle commands affect rectangular areas of text: all
  628. characters between a certain pair of columns, in a certain range of
  629. lines.  Commands are provided to kill rectangles, yank killed
  630. rectangles, clear them out, or delete them.  Rectangle commands are
  631. useful with text in multicolumnar formats, like code with comments at
  632. the right, or for changing text into or out of such formats.
  633.  
  634.    To specify the rectangle a command should work on, put the mark at
  635. one corner and point at the opposite corner.  The specified rectangle
  636. is called the "region-rectangle" because it is controlled about the
  637. same way the region is controlled.  Remember that a given combination
  638. of point and mark values can be interpreted either as specifying a
  639. region or as specifying a rectangle; it is up to the command that uses
  640. them to choose the interpretation.
  641.  
  642. `M-x delete-rectangle'
  643.      Delete the text of the region-rectangle, moving any following
  644.      text on each line leftward to the left edge of the
  645.      region-rectangle.
  646.  
  647. `M-x kill-rectangle'
  648.      Similar, but also save the contents of the region-rectangle as the
  649.      "last killed rectangle".
  650.  
  651. `M-x yank-rectangle'
  652.      Yank the last killed rectangle with its upper left corner at
  653.      point.
  654.  
  655. `M-x open-rectangle'
  656.      Insert blank space to fill the space of the region-rectangle. 
  657.      The previous contents of the region-rectangle are pushed
  658.      rightward.
  659.  
  660. `M-x clear-rectangle'
  661.      Clear the region-rectangle by replacing its contents with spaces.
  662.  
  663.    The rectangle operations fall into two classes: commands deleting
  664. and moving rectangles, and commands for blank rectangles.
  665.  
  666.    There are two ways to get rid of the text in a rectangle: you can
  667. discard the text (delete it) or save it as the "last killed"
  668. rectangle.  The commands for these two ways are `M-x delete-rectangle'
  669. and `M-x kill-rectangle'.  In either case, the portion of each line
  670. that falls inside the rectangle's boundaries is deleted, causing
  671. following text (if any) on the line to move left.
  672.  
  673.    Note that "killing" a rectangle is not killing in the usual sense;
  674. the rectangle is not stored in the kill ring, but in a special place
  675. that only records the most recently killed rectangle (that is, does not
  676. append to a killed rectangle).  Different yank commands have to be
  677. used and only one rectangle is stored because yanking a rectangle is
  678. quite different from yanking linear text and yank-popping commands are
  679. difficult to make sense of.
  680.  
  681.    Inserting a rectangle is the opposite of deleting one.  You specify
  682. where to put the upper left corner by putting point there.  The
  683. rectangle's first line is inserted at point, the rectangle's second
  684. line is inserted at a point one line vertically down, and so on.  The
  685. number of lines affected is determined by the height of the saved
  686. rectangle.
  687.  
  688.    To insert the last killed rectangle, type `M-x yank-rectangle'. 
  689. This can be used to convert single-column lists into double-column
  690. lists; kill the second half of the list as a rectangle and then yank
  691. it beside the first line of the list.
  692.  
  693.    There are two commands for working with blank rectangles: `M-x
  694. clear-rectangle' to blank out existing text, and `M-x open-rectangle'
  695. to insert a blank rectangle.  Clearing a rectangle is equivalent to
  696. deleting it and then inserting a blank rectangle of the same size.
  697.  
  698.    Rectangles can also be copied into and out of registers.  *Note
  699. Rectangle Registers: RegRect.
  700.  
  701. 
  702. File: emacs,  Node: Registers,  Next: Display,  Prev: Rectangles,  Up: Top
  703.  
  704. Registers
  705. *********
  706.  
  707.    Emacs "registers" are places in which you can save text or
  708. positions for later use.  Text saved in a register can be copied into
  709. the buffer once or many times; a position saved in a register is used
  710. by moving point to that position.  Rectangles can also be copied into
  711. and out of registers (*note Rectangles::.).
  712.  
  713.    Each register has a name, which is a single character.  A register
  714. can store either a piece of text or a position or a rectangle, but
  715. only one thing at any given time.  Whatever you store in a register
  716. remains there until you store something else in that register.
  717.  
  718. * Menu:
  719.  
  720. * RegPos::    Saving positions in registers.
  721. * RegText::   Saving text in registers.
  722. * RegRect::   Saving rectangles in registers.
  723.  
  724. `M-x view-register RET R'
  725.      Display a description of what register R contains.
  726.  
  727.    `M-x view-register' reads a register name as an argument and then
  728. displays the contents of the specified register.
  729.  
  730. 
  731. File: emacs,  Node: RegPos,  Next: RegText,  Prev: Registers,  Up: Registers
  732.  
  733. Saving Positions in Registers
  734. =============================
  735.  
  736.    Saving a position records a spot in a buffer so you can move back
  737. there later.  Moving to a saved position re-selects the buffer and
  738. moves point to the spot.
  739.  
  740. `C-x / R'
  741.      Save the location of point in register R (`point-to-register').
  742.  
  743. `C-x j R'
  744.      Jump to the location saved in register R (`register-to-point').
  745.  
  746.    To save the current location of point in a register, choose a name
  747. R and type `C-x / R'.  The register R retains the location thus saved
  748. until you store something else in that register.
  749.  
  750.    The command `C-x j R' moves point to the location recorded in
  751. register R.  The register is not affected; it continues to record the
  752. same location.  You can jump to the same position using the same
  753. register as often as you want.
  754.  
  755. 
  756. File: emacs,  Node: RegText,  Next: RegRect,  Prev: RegPos,  Up: Registers
  757.  
  758. Saving Text in Registers
  759. ========================
  760.  
  761.    When you want to insert a copy of the same piece of text many
  762. times, it can be impractical to use the kill ring, since each
  763. subsequent kill moves the piece of text further down on the ring.  It
  764. becomes hard to keep track of the argument needed to retrieve the same
  765. text with `C-y'.  An alternative is to store the text in a register
  766. with `C-x x' (`copy-to-register') and then retrieve it with `C-x g'
  767. (`insert-register').
  768.  
  769. `C-x x R'
  770.      Copy region into register R (`copy-to-register').
  771.  
  772. `C-x g R'
  773.      Insert text contents of register R (`insert-register').
  774.  
  775.    `C-x x R' stores a copy of the text of the region into the register
  776. named R.  Given a numeric argument, `C-x x' deletes the text from the
  777. buffer as well.
  778.  
  779.    `C-x g R' inserts the text from register R in the buffer.  By
  780. default it leaves point before the text and places the mark after it. 
  781. With a numeric argument, it puts point after the text and the mark
  782. before it.
  783.  
  784. 
  785. File: emacs,  Node: RegRect,  Prev: RegText,  Up: Registers
  786.  
  787. Saving Rectangles in Registers
  788. ==============================
  789.  
  790.    A register can contain a rectangle instead of lines of text.  The
  791. rectangle is represented as a list of strings.  *Note Rectangles::,
  792. for basic information on rectangles and how to specify rectangles in a
  793. buffer.
  794.  
  795. `C-x r R'
  796.      Copy the region-rectangle into register
  797.      R(`copy-region-to-rectangle').  With a numeric argument, delete
  798.      it as well.
  799.  
  800. `C-x g R'
  801.      Insert the rectangle stored in register R (if it contains a
  802.      rectangle) (`insert-register').
  803.  
  804.    The `C-x g' command inserts linear text if the register contains
  805. that, or inserts a rectangle if the register contains one.
  806.  
  807. 
  808. File: emacs,  Node: Display,  Next: Search,  Prev: Registers,  Up: Top
  809.  
  810. Controlling the Display
  811. ***********************
  812.  
  813.    Since only part of a large buffer fits in the window, Emacs tries
  814. to show the part that is likely to be interesting.  The display
  815. control commands allow you to specify which part of the text you want
  816. to see.
  817.  
  818. `C-l'
  819.      Clear screen and redisplay, scrolling the selected window to
  820.      center point vertically within it (`recenter').
  821.  
  822. `C-v'
  823.      Scroll forward (a windowful or a specified number of lines)
  824.      (`scroll-up').
  825.  
  826. `M-v'
  827.      Scroll backward (`scroll-down').
  828.  
  829. `ARG C-l'
  830.      Scroll so point is on line ARG (`recenter').
  831.  
  832. `C-x <'
  833.      Scroll text in current window to the left (`scroll-left').
  834.  
  835. `C-x >'
  836.      Scroll to the right (`scroll-right').
  837.  
  838. `C-x $'
  839.      Make deeply indented lines invisible (`set-selective-display').
  840.  
  841. * Menu:
  842.  
  843. * Scrolling::               Moving text up and down in a window.
  844. * Horizontal Scrolling::   Moving text left and right in a window.
  845. * Selective Display::      Hiding lines with lots of indentation.
  846. * Display Vars::           Information on variables for customizing display.
  847.  
  848. 
  849. File: emacs,  Node: Scrolling,  Next: Horizontal Scrolling,  Prev: Display,  Up: Display
  850.  
  851. Scrolling
  852. =========
  853.  
  854.    If a buffer contains text that is too large to fit entirely within
  855. the window that is displaying the buffer, Emacs shows a contiguous
  856. section of the text.  The section shown always contains point.
  857.  
  858.    "Scrolling" means moving text up or down in the window so that
  859. different parts of the text are visible.  Scrolling forward means that
  860. text moves up, and new text appears at the bottom.  Scrolling backward
  861. moves text down and new text appears at the top.
  862.  
  863.    Scrolling happens automatically if you move point past the bottom
  864. or top of the window.  You can also explicitly request scrolling with
  865. the commands in this section.
  866.  
  867. `C-l'
  868.      Clear screen and redisplay, scrolling the selected window to
  869.      center point vertically within it (`recenter').
  870.  
  871. `C-v'
  872.      Scroll forward (a windowful or a specified number of lines)
  873.      (`scroll-up').
  874.  
  875. `M-v'
  876.      Scroll backward (`scroll-down').
  877.  
  878. `ARG C-l'
  879.      Scroll so point is on line ARG (`recenter').
  880.  
  881.    The most basic scrolling command is `C-l' (`recenter') with no
  882. argument.  It clears the entire screen and redisplays all windows.  In
  883. addition, it scrolls the selected window so that point is halfway down
  884. from the top of the window.
  885.  
  886.    The scrolling commands `C-v' and `M-v' let you move all the text in
  887. the window up or down a few lines.  `C-v' (`scroll-up') with an
  888. argument shows you that many more lines at the bottom of the window,
  889. moving the text and point up together as `C-l' might.  `C-v' with a
  890. negative argument shows you more lines at the top of the window. 
  891. `Meta-v' (`scroll-down') is like `C-v', but moves in the opposite
  892. direction.
  893.  
  894.    To read the buffer a windowful at a time, use `C-v' with no
  895. argument.  `C-v' takes the last two lines at the bottom of the window
  896. and puts them at the top, followed by nearly a whole windowful of
  897. lines not previously visible.  Point moves to the new top of the window
  898. if it was in the text scrolled off the top.  `M-v' with no argument
  899. moves backward with similar overlap.  The number of lines of overlap
  900. across a `C-v' or `M-v' is controlled by the variable
  901. `next-screen-context-lines'; by default, it is two.
  902.  
  903.    Another way to scroll is using `C-l' with a numeric argument. 
  904. `C-l' does not clear the screen when given an argument; it only
  905. scrolls the selected window.  With a positive argument N,`C-l'
  906. repositions text to put point N lines down from the top.  An argument
  907. of zero puts point on the very top line.  Point does not move with
  908. respect to the text; rather, the text and point move rigidly on the
  909. screen.  `C-l' with a negative argument puts point that many lines
  910. from the bottom of the window.  For example, `C-u - 1 C-l' puts point
  911. on the bottom line, and `C-u - 5 C-l' puts it five lines from the
  912. bottom.  Just `C-u' as argument, as in `C-u C-l', scrolls point to the
  913. center of the screen.
  914.  
  915.    Scrolling happens automatically if point has moved out of the
  916. visible portion of the text when it is time to display.  Usually
  917. scrolling is done  to put point vertically centered within the window.
  918.  However, if the variable `scroll-step' has a non-zero value, an
  919. attempt is made to scroll the buffer by that many lines; if that is
  920. enough to bring point back into visibility, that is what happens.
  921.  
  922. 
  923. File: emacs,  Node: Horizontal Scrolling,  Prev: Scrolling,  Up: Display
  924.  
  925. Horizontal Scrolling
  926. ====================
  927.  
  928. `C-x <'
  929.      Scroll text in current window to the left (`scroll-left').
  930.  
  931. `C-x >'
  932.      Scroll to the right (`scroll-right').
  933.  
  934.    The text in a window can also be scrolled horizontally.  This means
  935. that each line of text is shifted sideways in the window, and one or
  936. more characters at the beginning of each line are not displayed at
  937. all.  When a window has been scrolled horizontally in this way, text
  938. lines are truncated rather than continued (*note Continuation
  939. Lines::.), with a `$' appearing in the first column when there is text
  940. truncated to the left, and in the last column when there is text
  941. truncated to the right.
  942.  
  943.    The command `C-x <' (`scroll-left') scrolls the selected window to
  944. the left by N columns with argument N.  With no argument, it scrolls
  945. by almost the full width of the window (two columns less, to be
  946. precise).  `C-x >' (`scroll-right') scrolls similarly to the right. 
  947. The window cannot be scrolled any farther to the right once it is
  948. displaying normally (with each line starting at the window's left
  949. margin); attempting to do so has no effect.
  950.  
  951. 
  952. File: emacs,  Node: Selective Display,  Next: Display Vars,  Prev: Display,  Up: Display
  953.  
  954. Selective Display
  955. =================
  956.  
  957.    Emacs can hide lines indented more than a certain number of columns
  958. (you specify how many columns).  This allows you  to get an overview
  959. of a part of a program.
  960.  
  961.    To hide lines, type `C-x $' (`set-selective-display') with a
  962. numeric argument N.  (*Note Arguments::, for information on giving the
  963. argument.)  Lines with at least N columns of indentation disappear
  964. from the screen.  The only indication of their presence are three dots
  965. (`...'), which appear at the end of each visible line that is followed
  966. by one or more invisible ones.
  967.  
  968.    The invisible lines are still present in the buffer, and most
  969. editing commands see them as usual, so it is very easy to put point in
  970. the middle of invisible text.  When this happens, the cursor appears
  971. at the end of the previous line, after the three dots.  If point is at
  972. the end of the visible line, before the newline that ends it, the
  973. cursor appears before the three dots.
  974.  
  975.    The commands `C-n' and `C-p' move across the invisible lines as if
  976. they were not there.
  977.  
  978.    To make everything visible again, type `C-x $' with no argument.
  979.  
  980. 
  981. File: emacs,  Node: Display Vars,  Prev: Selective Display,  Up: Display
  982.  
  983. Variables Controlling Display
  984. =============================
  985.  
  986.    This section contains information for customization only.  Beginning
  987. users should skip it.
  988.  
  989.    The variable `mode-line-inverse-video' controls whether the mode
  990. line is displayed in inverse video (assuming the terminal supports it);
  991. `nil' means don't do so.  *Note Mode Line::.
  992.  
  993.    If the variable `inverse-video' is non-`nil', Emacs attempts to
  994. invert all the lines of the display from what they normally are.
  995.  
  996.    When you reenter Emacs after suspending, Emacs normally clears the
  997. screen and redraws the entire display.  On some terminals with more
  998. than one page of memory, it is possible to arrange the termcap entry
  999. so that the `ti' and `te' strings (output to the terminal when Emacs
  1000. is entered and exited, respectively) switch between pages of memory so
  1001. as to use one page for Emacs and another page for other output.  In
  1002. that case, you might want to set the variable `no-redraw-on-reenter'
  1003. non-`nil' so that Emacs will assume, when resumed, that the screen
  1004. page it is using still contains what Emacs last wrote there.
  1005.  
  1006.    The variable `echo-keystrokes' controls the echoing of
  1007. multi-character keys; its value is the number of seconds of pause
  1008. required to cause echoing to start, or zero meaning don't echo at all.
  1009.  *Note Echo Area::.
  1010.  
  1011.    If the variable `ctl-arrow' is `nil', control characters in the
  1012. buffer are displayed with octal escape sequences, all except newline
  1013. and tab.  If its value is `t', then control characters will be printed
  1014. with an uparrow, for example `^A'.
  1015.  
  1016.    If its value is not `t' and not `nil', then characters whose code
  1017. is greater than 160 (that is, the space character (32) with its high
  1018. bit set) will be assumed to be printable, and will be displayed
  1019. without alteration.  This is the default when running under X Windows,
  1020. since Lucid Emacs assumes an ISO/8859-1 character set (also known as
  1021. "Latin1").  The `ctl-arrow' variable may also be set to an integer, in
  1022. which case all characters whose codes are greater than or equal to
  1023. that value will be assumed to be printable.
  1024.  
  1025.    Altering the value of `ctl-arrow' makes it local to the current
  1026. buffer; until that time, the default value is in effect.  *Note
  1027. Locals::.
  1028.  
  1029.    Normally, a tab character in the buffer is displayed as whitespace
  1030. which extends to the next display tab stop position, and display tab
  1031. stops come at intervals equal to eight spaces.  The number of spaces
  1032. per tab is controlled by the variable `tab-width', which is made local
  1033. by changing it, just like `ctl-arrow'.  Note that how the tab character
  1034. in the buffer is displayed has nothing to do with the definition of
  1035. TAB as a command.
  1036.  
  1037.    If you set the variable `selective-display-ellipses' to `nil', the
  1038. three dots at the end of a line that precedes invisible lines do not
  1039. appear.  There is no visible indication of the invisible lines.  This
  1040. variable becomes local automatically when set.
  1041.  
  1042. 
  1043. File: emacs,  Node: Search,  Next: Fixit,  Prev: Display,  Up: Top
  1044.  
  1045. Searching and Replacement
  1046. *************************
  1047.  
  1048.    Like other editors, Emacs has commands for searching for
  1049. occurrences of a string.  The principal search command is unusual in
  1050. that it is "incremental": it begins to search before you have finished
  1051. typing the search string.  There are also non-incremental search
  1052. commands more like those of other editors.
  1053.  
  1054.    Besides the usual `replace-string' command that finds all
  1055. occurrences of one string and replaces them with another, Emacs has a
  1056. fancy replacement command called `query-replace' which asks
  1057. interactively which occurrences to replace.
  1058.  
  1059. * Menu:
  1060.  
  1061. * Incremental Search::     Search happens as you type the string.
  1062. * Non-Incremental Search::  Specify entire string and then search.
  1063. * Word Search::            Search for sequence of words.
  1064. * Regexp Search::          Search for match for a regexp.
  1065. * Regexps::                Syntax of regular expressions.
  1066. * Search Case::            To ignore case while searching, or not.
  1067. * Replace::                Search, and replace some or all matches.
  1068. * Other Repeating Search:: Operating on all matches for some regexp.
  1069.  
  1070.